<?PHP

  $files = glob(dirname(dirname(__FILE__)) . '/settings/*.*');
  $versions = array();

  foreach ($files as $file) {
   list($type, $channel, $version) = explode('-', substr(basename($file), 0, strpos(basename($file), '.')));

   if (!isset($versions[$channel][$type][0]) || (int) $version > $versions[$channel][$type][0]) {
    $versions[$channel][$type] = array((int) $version, basename($file));
   }
  }

  foreach ($versions as $channel => $data1) {
   foreach ($data1 as $type => $data) {
    list($version, $file) = $data;

    $_VERSIONS[$type][$channel] = array(
	'id' => $version,
	'string' => $version,
	'file' => 'http://updates.dmdirc.com/settings/' . $file
    );
   }
  }

?>
